package com.jl.jlapp.mvp.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.BindView;
import butterknife.ButterKnife;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.jl.jlapp.R;
import com.jl.jlapp.adapter.GoodsListAdapter2;
import com.jl.jlapp.eneity.AdvertisementByIdModel;
import com.jl.jlapp.mvp.activity.GoodsDetailActivity;
import com.jl.jlapp.utils.CustomGridLayoutManager;

import java.util.ArrayList;
import java.util.List;

public class FirstPageHotSaleGoodsListFragment extends Fragment {
    Fragment_FirstPages fragment_firstPages = new Fragment_FirstPages();
    List<AdvertisementByIdModel.ResultDataBean.GoodsBean> goodsList;
    GoodsListAdapter2 goodsListAdapter;
    int page;
    @BindView(R.id.show_goods_list_view)
    RecyclerView showGoodsListView;
    View view;

    private List<AdvertisementByIdModel.ResultDataBean.GoodsBean> getDataByPage(int paramInt) {
        ArrayList localArrayList = new ArrayList();
        paramInt = 0;
        while (paramInt < 3) {
            if (paramInt < this.goodsList.size()) {
                localArrayList.add((AdvertisementByIdModel.ResultDataBean.GoodsBean) this.goodsList.get(paramInt));
            }
            paramInt += 1;
        }
        paramInt = 3;
        while (paramInt < 6) {
            if (paramInt < this.goodsList.size()) {
                localArrayList.add((AdvertisementByIdModel.ResultDataBean.GoodsBean) this.goodsList.get(paramInt));
            }
            paramInt += 1;
        }
        paramInt = 6;
        while (paramInt < 9) {
            if (paramInt < this.goodsList.size()) {
                localArrayList.add((AdvertisementByIdModel.ResultDataBean.GoodsBean) this.goodsList.get(paramInt));
            }
            paramInt += 1;
        }
        return localArrayList;
    }

    public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle) {
        this.view = paramLayoutInflater.inflate(R.layout.first_page_hot_goods_fragment, null, false);
        ButterKnife.bind(this, this.view);
        this.page = getArguments().getInt("page");
        this.goodsList = Fragment_FirstPages.promotionGoodsList;
        setAdapter();
        return this.view;
    }

    public void setAdapter() {
        this.showGoodsListView.setLayoutManager(new CustomGridLayoutManager(getActivity(), 3, false));
        this.goodsListAdapter = new GoodsListAdapter2(getDataByPage(this.page));
        this.showGoodsListView.setAdapter(this.goodsListAdapter);
        goodsListAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Intent localIntent = new Intent(FirstPageHotSaleGoodsListFragment.this.getActivity(), GoodsDetailActivity.class);
                localIntent.putExtra("goodsId", ((AdvertisementByIdModel.ResultDataBean.GoodsBean) adapter.getData().get(position)).getId());
                FirstPageHotSaleGoodsListFragment.this.startActivity(localIntent);
            }
        });
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/fragment/FirstPageHotSaleGoodsListFragment.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */